var a = require("../../../../mybehaviors/location/location"), t = getApp();

Component({
    behaviors: [ a ],
    properties: {
        params: {
            type: null
        },
        index: {
            type: null
        },
        data: {
            type: null
        },
        designer: {
            type: null
        },
        sessionurl: {
            type: null
        },
        Identification: {
            type: null
        },
        grouid: {
            type: null
        },
        total: {
            type: null
        }
    },
    data: {
        language: "",
        showMore: !0,
        page: 1,
        total_page: 0,
        isLoadMore: !0,
        goodsShow: !0
    },
    lifetimes: {
        attached: function() {
            var a = this, t = wx.getStorageSync("langIndex");
            this.setData({
                language: t.en
            }), this._getLocation(function() {
                a.getdata();
            });
        },
        moved: function() {},
        detached: function() {}
    },
    attached: function() {},
    ready: function() {},
    pageLifetimes: {
        show: function() {},
        hide: function() {},
        resize: function() {}
    },
    methods: {
        gotoDetail: function(a) {
            var t = a.currentTarget.dataset.good.goodid;
            wx.navigateTo({
                url: "/packageA/detail_v2/detail_v2?id=" + t
            });
        },
        getMoreData: function() {
            var a = this;
            if (console.log(a.data.current_page, a.data.last_page), !(a.data.current_page >= a.data.last_page)) {
                a.setData({
                    page: a.data.page + 1
                });
                var e = wx.getStorageSync("address-point");
                console.log(a.data.params.display_num);
                var o = t.getNetAddresss("plugin.nearby-store-goods.frontend.controllers.designer.get-goods"), s = t.qqMapTransBMap(parseFloat(e.point.lng), parseFloat(e.point.lat));
                o += "&page=" + a.data.page, o += "&lng=" + s.lng, o += "&lat=" + s.lat, o += "&city_name=" + e.city, 
                o += "&display_num=" + a.data.params.displaynum, t._getNetWork({
                    url: o,
                    success: function(t) {
                        var e = t.data;
                        if (1 == e.result) {
                            var o = a.data.data;
                            a.setData({
                                data: o.concat(e.data.data),
                                current_page: e.data.current_page,
                                last_page: e.data.last_page
                            }), a.data.current_page <= a.data.last_page ? a.setData({
                                isLoadMore: !1
                            }) : a.data.current_page > a.data.last_page && a.setData({
                                isLoadMore: !0
                            });
                        } else a.setData({
                            page: a.data.page - 1,
                            isLoadMore: !1
                        });
                    },
                    fail: function(a) {
                        console.log(a);
                    }
                });
            }
        },
        getdata: function() {
            var a = this, e = wx.getStorageSync("address-point"), o = {};
            console.log(a.data.params.display_num);
            var s = t.getNetAddresss("plugin.nearby-store-goods.frontend.controllers.designer.get-goods");
            o = e ? t.qqMapTransBMap(parseFloat(e.point.lng), parseFloat(e.point.lat)) : {
                lng: "",
                lat: ""
            }, s += "&page=" + a.data.page, s += "&lng=" + o.lng, s += "&lat=" + o.lat, s += "&city_name=" + e.city, 
            s += "&display_num=" + a.data.params.displaynum, t._getNetWork({
                url: s,
                success: function(t) {
                    var e = t.data;
                    if (1 == e.result) {
                        a.setData({
                            data: [].concat(e.data.data),
                            current_page: e.data.current_page,
                            last_page: e.data.last_page
                        }), wx.setStorageSync("fjstore", e.data.data), e.data.current_page < e.data.last_page ? a.setData({
                            isLoadMore: !0
                        }) : e.data.current_page >= e.data.last_page && a.setData({
                            isLoadMore: !1
                        }), console.log(e.data.data), e.data.data <= 0 && a.setData({
                            goodsShow: !1
                        }), console.log(e), console.log(a.data.isLoadMore);
                    } else a.setData({
                        page: a.data.page - 1,
                        isLoadMore: !1
                    });
                },
                fail: function(a) {
                    console.log(a);
                }
            });
        }
    },
    observers: {
        params: function() {
            console.log(this.data.params), this.setData({
                showMore: !0,
                page: 1,
                total_page: 0,
                isLoadMore: !0
            }), this.setData({
                total_page: this.data.total
            }), console.log(this.data.total_page), this.data.page >= this.data.total_page && this.setData({
                isLoadMore: !1
            });
        }
    }
});